/**
 * Copyright(c) 2013 Jade Techonologies Co., Ltd.
 *
 * History:
 *   13-7-5 下午4:50 Created by dwzhang
 */
package com.jade.framework.base.text;

import com.jade.framework.base.util.Parameters;
import org.apache.velocity.VelocityContext;

/**
 * 带Parameters的上下文。
 *
 * @author dwzhang
 * @version 1.0 13-7-5 下午4:50
 */
public class ParamsVelocityContext extends VelocityContext
{
    private Parameters parameters = null;

    public ParamsVelocityContext()
    {
        super();
    }

    public ParamsVelocityContext(Parameters params)
    {
        parameters = params;
        put("container", params);
    }

    public Object internalGet(String name)
    {
        Object value = null;
        if (parameters != null) {
            value = parameters.getObject(name);
        }
        if (value == null) {
            value = super.internalGet(name);
        }

        return value;
    }

    public Object put(String s, Object obj)
    {
        if (obj == null) {
            obj = "";
        }
        return super.put(s, obj);
    }
}

